<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>教师主页</title>
    <link rel="stylesheet" href="tHome.css">
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<div class="header">
    <div class="header1">欢迎进入教室信息管理系统教师端</div>
    <div class="header2">
        <span><img src="img/user.png" class="userpng"><a class="show" href="#">HOME</a></span>
        |
        <span><a href="http://localhost:8080/ClassroomManageSystem_war_exploded/切换.html">退出</a></span>
    </div>
    <div class="teachermsg">
        <c:choose>
            <c:when test="${requestScope.teacher != null}">
                <table>
                    <tr>
                        <td>编号：</td>
                        <td>${requestScope.teacher.tid}</td>
                    </tr>
                    <tr>
                        <td>姓名：</td>
                        <td>${requestScope.teacher.tname}</td>
                    </tr>
                    <tr>
                        <td>教授课程：</td>
                        <td>${requestScope.teacher.course}</td>
                    </tr>
                    <tr>
                        <td>职称：</td>
                        <td>${requestScope.teacher.level}</td>
                    </tr>
                </table>
                <span class="banner"><a href="http://localhost:8080/ClassroomManageSystem_war_exploded/teacherServlet?action=getTeacher&tid=${requestScope.teacher.tid}">编辑资料</a> </span>
            </c:when>
            <c:when test="${requestScope.msg != null}">
                <h4>${requestScope.msg}</h4>
            </c:when>
        </c:choose>

    </div>

</div>
<div class="nav">
   <ul class="nav1">
       <li>
           <a href="http://localhost:8080/ClassroomManageSystem_war_exploded/teacherServlet?action=SelectAllClassroom">查询教室</a>
       </li>
       <li>
           <a href="http://localhost:8080/ClassroomManageSystem_war_exploded/teacherServlet?action=SelectAllCourse&tid=${requestScope.teacher.tid}">我的课表</a>
       </li>
   </ul>
</div>

<div id="content">
    <table id="tabletest">

    </table>
<button id="btn">查看今天的课表</button>
</div>
<script type="text/javascript">
    $(function () {
        //ajax请求
        $("#content").click(function () {
            $.ajax({
                url:"http://localhost:8080/ClassroomManageSystem_war_exploded/teacherServlet",
                data:"action=selectCourseNow&tid=${requestScope.teacher.tid}",
                type:"GET",
                success:function (date) {
                    $("#tabletest").append("<tr>\n" +
                        "            <th>教室号</th>\n" +
                        "            <th>课程名</th>\n" +
                        "            <th>教室类型</th>\n" +
                        "            <th>教室设备</th>\n" +
                        "            <th>开始时间</th>\n" +
                        "            <th>结束时间</th>\n" +
                        "        </tr>")
                    for (i in date){

                        var tr = "<td>"+date[i].clnum+"</td><td>"+date[i].course+"</td><td>"+date[i].type+"</td><td>"+date[i].medium+"</td><td>"+date[i].start+"</td><td>"+date[i].end+"</td>"
                        $("#tabletest").append("<tr>"+tr+"</tr>")
                    }
                    $("#btn").remove();
                },
                dataType:"json"
            })
        })
    })
</script>

<script>
    var timer;
        $("a.show,.teachermsg").bind("mouseover",showMsgBox);
        $("a.show").bind("mouseout",hideMsgBox);
        $(".teachermsg").bind("mouseout",function () {
            if(timer){clearTimeout(timer);}
            $(".teachermsg").hide();
        });
        function showMsgBox() {
            if(timer){clearTimeout(timer);}
            $(".teachermsg").show();
        }
        function hideMsgBox() {
            timer=setTimeout(function () {
                $(".teachermsg").hide();
            },500);
        }
</script>

</body>
</html>